package com.heba.helper;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import java.util.List;

/**
 * 社交分享help
 * Created by jason on 2020/3/23.
 */
public class SocialShareHelper {

    public final static String packageWeixin = "com.tencent.mm";

    public final static String packageFacebook = "com.facebook.katana";

    public final static String packageWhatsApp = "com.whatsapp";

    //判断有没有安装微信
    public static boolean isApkExist(Context context, String packageName) {
        final PackageManager packageManager = context.getPackageManager();// 获取packagemanager
        List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息
        if (pinfo != null) {
            for (int i = 0; i < pinfo.size(); i++) {
                String pn = pinfo.get(i).packageName;
                if (pn.equals(packageName)) {
                    return true;
                }
            }
        }
        return false;
    }

}
